<?php
define('FPDF_FONTPATH', 'font/');
require('./font/fpdf.php');
include("include/config.inc.php");
include("amountToWords.php");

{
  $pdf=new FPDF('P','mm','A4');   //Create new pdf file
  $pdf->Open();     //Open file
  $pdf->SetAutoPageBreak(false);  //Disable automatic page break
  $pdf->AddPage();  //Add first page

  
  $i         = 0; 
  $rowHeight = 6;
  $yAxis     = 5;

  $yAxis = $yAxis + $rowHeight;
  
  $pdf->SetDrawColor(255, 51, 51);
  $pdf->SetFont('Arial', '', 12);
  $pdf->SetXY(5,5);
  $pdf->Cell(200, 155, '', 1, 0, 'L', 0);
  $pdf->SetXY(4,4);
  $pdf->Cell(202, 157, '', 1, 0, 'L', 0);
  
  
//  $pdf->SetFillColor(232, 232, 232);
//  $pdf->SetFont('Arial', '', 10);
//  $pdf->SetXY(5,$yAxis);
//  $pdf->Cell(25, 6, 'loanId', 1, 0, 'C', 0);
//  $pdf->Cell(15, 6, 'partyId',        1, 0, 'C', 0);
  
  $pdf->SetTextColor(0, 0, 102);
  $pdf->SetFont('Arial', '', 10);
  $pdf->SetXY(167,$yAxis);
  
  $pdf->SetFillColor(232, 232, 232);
  $pdf->AddFont('Saumil_guj2', '', 'Saumil_guj2.php');
  $pdf->SetFont('Saumil_guj2', '', 14);
  $pdf->SetXY(5,5);
  $pdf->Cell(70, 10, 'maaobaa[la : 9824285939, 9429314212, ', 0, 0, 'L', 0);
  
  $pdf->SetXY(21,10);
  $pdf->Cell(70, 10, ' 9979205992', 0, 0, 'L', 0);
  
  $pdf->SetXY(90,5);
  $pdf->Cell(30, 10, '!! Jya maataaP !! ', 0, 0, 'L', 0);
  
  $pdf->SetXY(135	,5);
  $pdf->Cell(70, 10, 'sarkar maanya ', 0, 0, 'R', 0);
  
  $pdf->SetXY(135	,10);
  $pdf->Cell(70, 10, 'laa.naM 87  2003 ', 0, 0, 'R', 0);
  $pdf->SetXY(190	,10);
  $pdf->SetFont('arial','', 15);
  $pdf->Write(10,'/');
  
  
  $pdf->SetTextColor(0,0,102);
  $pdf->SetFillColor(255, 153, 153);
  $pdf->SetFont('Saumil_guj2', '', 40);
  $pdf->SetTextColor(0,0,102);
  $pdf->SetXY(5,20);
  $pdf->RoundedRect(6,20,95,15,3.5,'DF');
  $pdf->Cell(95, 15, '  iSavaSaikta fa[naansa', 0, 0, 'L', 0);
  
  $pdf->SetTextColor(0, 0, 102);
  $pdf->SetFont('Saumil_guj2', '', 15);
  $pdf->SetXY(5,35);
  $pdf->Cell(200, 10, ' 102, baMsaI kaompalaoxa, 80fuT rIMga raoD, maa#ita haolanaI saamao, gaaMVIga`ama, raJkaoT.', 0, 0, 'L', 0);
  
  $pdf->SetXY(6,45);
  $pdf->RoundedRect(6,46,25,7,3.5,'B');
  $pdf->Cell(25, 8, 'naama :', 0, 0, 'L', 0);
  $pdf->SetXY(6,53);
  $pdf->RoundedRect(6,54,25,7,3.5,'B');
  $pdf->Cell(25, 8, 'sarnaamau :', 0, 0, 'L', 0);
  $pdf->SetXY(6,61);
  $pdf->RoundedRect(6,62,25,7,3.5,'B');
  $pdf->Cell(25, 8, 'Kaataa naM. :', 0, 0, 'L', 0);
  $pdf->SetXY(105,61);
  $pdf->RoundedRect(105,62,25,7,3.5,'B');
  $pdf->Cell(25, 8, '  taarIKa :', 0, 0, 'L', 0);
  $pdf->SetXY(6,69);
  $pdf->RoundedRect(6,70,25,7,3.5,'B');
  $pdf->Cell(25, 8, 'vaJna :', 0, 0, 'L', 0);
  $pdf->SetXY(6,77);
  $pdf->RoundedRect(6,78,25,7,3.5,'B');
  $pdf->Cell(25, 8, 'vastau :', 0, 0, 'L', 0);
  $pdf->SetXY(6,85);
  $pdf->RoundedRect(6,86,25,7,3.5,'B');
  $pdf->Cell(25, 8, 'VIrola #a. :', 0, 0, 'L', 0);
  
  $pdf->SetXY(5,95);
  $pdf->Cell(25, 6, 'Sartaao :', 0, 0, 'L', 0);
  $pdf->SetXY(5,105);
  $pdf->Cell(200, 5, '1.vaaiYa-k dr 18 Tka', 0, 0, 'L', 0);
  $pdf->SetXY(5,110);
  $pdf->Cell(200, 5, '2. vyaaJ dr maihnao inayaimata BarvauM.', 0, 0, 'L', 0);
  $pdf->SetXY(5,115);
  $pdf->Cell(200, 5, '3. 3 maasanau vyaaJ caDola haoya taao tamaarI JvaabadarqaI maala vaoMcaI naaKavaamaaM AavaSao.', 0, 0, 'L', 0);
  $pdf->SetXY(5,120);
  $pdf->Cell(200, 5, '4. 3 maasa paCI iSavaSaikta fa[naansanaI kao[paNa JvaabadarI rhoSao naih.  ', 0, 0, 'L', 0);
  $pdf->SetXY(5,125);
  $pdf->Cell(200, 5, '5. maalanaI ikMmata krvaanaao caaJ- dovaanaao rhoSao.  ', 0, 0, 'L', 0);
  $pdf->SetXY(5,130);
  $pdf->Cell(200, 5, '6. savaaro paOsaa AapaI vastau CaoDvaamaa saaMJo AavavaanauM rhoSao.  ', 0, 0, 'L', 0);
  $pdf->SetXY(5,135);
  $pdf->Cell(200, 5, '7. vastaunaI saMpauNa- JvaabadarI Jo tao maalaIk naI rhoSao.  ', 0, 0, 'L', 0);
  $pdf->SetXY(5,140);
  $pdf->Cell(200, 5, '8. jao vastau caaorI ko GarfaoDInaI hSao taao jo tao vyaktaInaI jvaabadarI rhoSao.  ', 0, 0, 'L', 0);
  $pdf->SetXY(5,145);
  $pdf->Cell(200, 5, '    tao vyaktaI samaxa kanaunaI pagalaa laovaamaaM AavaSao.  ', 0, 0, 'L', 0);
  $pdf->SetXY(5,150);
  $pdf->Cell(200, 5, '    Aa baabatao pao@InaI kao[ paNa jatanaI jvaabadarI rhoSao nahI.  ', 0, 0, 'L', 0);
  $pdf->SetXY(5,155);
  $pdf->Cell(200, 5, '9. nyaaya xao~a raJkaoT.  ', 0, 0, 'L', 0);
  $pdf->SetTextColor(255,51,51);
  $pdf->SetXY(100,155);
  $pdf->Cell(30, 5, ' ga`ahknaI sahI.  ', 0, 0, 'L', 0);
  $pdf->SetXY(158,155);
  $pdf->Cell(55, 5, 'EaI iSavaSaikta fa[naansa vataI,  ', 0, 0, 'L', 0);
  
  
  
  //table header part end 
  if(isset($_GET['loanId']))
  {
    $selectChallan = "SELECT party.gPartyName,party.gAddress,loan.loanId,DATE_FORMAT(loan.loanDate ,'%d-%m-%Y') AS loanDate,
                             loan.weight,item.itemNameGuj,loan.loanAmount,loan.loanVarNo
                        FROM loan
                   LEFT JOIN party ON party.partyId = loan.partyId
                   LEFT JOIN item ON item.itemId = loan.itemId
                       WHERE loan.loanId = ".$_GET['loanId'];
    $selectChallanRes = mysql_query($selectChallan);
    while($selectRow  = mysql_fetch_array($selectChallanRes))
    {                                             
      $loanId     = $selectRow['loanId'];
      $partyName  = $selectRow['gPartyName'];
      $address    = $selectRow['gAddress'];
      $loanDate   = $selectRow['loanDate'];
      $weight     = $selectRow['weight'];
      $itemName   = $selectRow['itemNameGuj'];
      $loanAmount = $selectRow['loanAmount'];
      $loanVarNo  = $selectRow['loanVarNo'];
    }
  }
  $pdf->SetTextColor(255,51,51);
  $pdf->SetFont('Saumil_guj2', '', 20);
  $pdf->SetXY(140,20);
  $pdf->RoundedRect(140,22,62,10,3.5,'B');
  $pdf->Cell(25, 15, 'pahaoca naM.', 0, 0, 'L', 0);
  $pdf->Cell(37, 15,$loanId, 0, 0, 'L', 0);
  
  $pdf->SetTextColor(0, 0, 102);
  $pdf->SetFont('arial','', 12);
  $pdf->SetXY(34,46);
  $pdf->RoundedRect(32,46,170,7,3.5,'B');
  $pdf->Cell(175, 8, $partyName, 0, 0, 'L', 0);
  $pdf->SetXY(34,54);
  $pdf->RoundedRect(32,54,170,7,3.5,'B');
  $pdf->Cell(175, 8, $address, 0, 0, 'L', 0);
  $pdf->SetXY(34,62);
  $pdf->RoundedRect(32,62,71,7,3.5,'B');
  $pdf->Cell(75, 8, $loanVarNo, 0, 0, 'L', 0);
  $pdf->SetXY(134,62);
  $pdf->RoundedRect(132,62,70,7,3.5,'B');
  $pdf->Cell(75, 8, $loanDate, 0, 0, 'L', 0);
  $pdf->SetXY(34,70);
  $pdf->RoundedRect(32,70,170,7,3.5,'B');
  $pdf->Cell(175, 8, $weight, 0, 0, 'L', 0);
  $pdf->SetXY(34,78);
  $pdf->RoundedRect(32,78,170,7,3.5,'B');
  $pdf->Cell(175, 8, $itemName, 0, 0, 'L', 0);
  $pdf->SetXY(34,86);
  $pdf->RoundedRect(32,86,170,7,3.5,'B');
  $pdf->Cell(175, 8, $loanAmount, 0, 0, 'L', 0);

//  $pdf->SetFillColor(232, 232, 232);
//  $pdf->SetXY(5,$yAxis+8);
//  $pdf->SetFont('Arial', '', 10);
//  $pdf->SetXY(5,$yAxis+14);
//  $pdf->SetXY(5,$yAxis+20);
//  $pdf->SetXY(5,$yAxis+26);
//  
//  $pdf->SetFillColor(232, 232, 232);
//  $pdf->SetXY(87,$yAxis+8);
//  $pdf->SetFont('Arial', '', 10);
//  $pdf->SetXY(87,$yAxis+16);
//  $pdf->SetXY(87,$yAxis+24);
  
  $pdf->Output();
}
?>